﻿using Abp.AutoMapper;
using Paas.Core.Sys.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;

namespace Paas.App.Interface.Sys.Data.Dtos
{
    [AutoMap(typeof(Organization))]
    public class OrganizationDataDto
    {
        [JsonPropertyName("value")]
        [Newtonsoft.Json.JsonProperty("value")]
        public int Id { get; set; }

        [JsonPropertyName("label")]
        [Newtonsoft.Json.JsonProperty("label")]
        public string Name { get; set; }

        [JsonIgnore]
        public int? ParentId { get; set; }

        [JsonPropertyName("parent")]
        [Newtonsoft.Json.JsonProperty("parent")]
        public int Parent => ParentId ?? 0;

        [JsonIgnore]
        public bool IsLeaf => !Children?.Any() ?? false;

        [JsonPropertyName("children")]
        [Newtonsoft.Json.JsonProperty("children")]
        public List<OrganizationDataDto> Children { get; set; }

    }
}

